How to read files using StreamReader in C#?
How to read file using StreamReader in C#?
571
13-Jun-2024
Ashutosh Kumar Verma
13-Jun-2024C# StreamReader for Reading file
In C#, reading a file using the
StreamReaderclass is simple.Example-
Here is a simple example to read data from text file using StreamReader class in C#,
In the above example-
File.Exists(filePath)to check if the file exists.StreamReaderinstance named reader and pass the file path to its constructor.ReadLine()method of theStreamReaderinstance.Output-
Also, Read: How to write file using StreamWriter in C#?